package com.kingyun.gpsinspection.purificationservice.facade.service.jsm.singlework;

import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.*;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * Created by YuPeng on 2016/12/15.
 * 单项工作步骤Service层
 * 包含：
 * 步骤的增删改查、
 * 单项工作阈值的增删该查、
 * 数据项的增删改查
 */
public interface JsmSingleWorkService {
    /**
     * 添加单项工作步骤
     * @param singleWorkStep
     * @return
     * @throws Exception
     */
    Map<String,Object> add(SingleWorkStep singleWorkStep, Employee employee) throws Exception;


    /**
     * 批量导入单项工作步骤
     * @param excel
     * @param workInstanceId
     * @return
     * @throws Exception
     */
    Map<String, Object> importStep(MultipartFile excel, String workInstanceId, BigDecimal version, Employee employee) throws Exception;
    /**
     * 导入操作单元工作步骤
     * @param stepIds
     * @param workInstanceId
     * @param version
     * @return
     * @throws Exception
     */
    Map<String,Object> importUnitStep(List<String> stepIds, String workInstanceId, BigDecimal version, Employee employee) throws Exception;
    /**
     * 修改单项工作步骤
     * @param singleWorkStep
     * @return
     * @throws Exception
     */
    Map<String,Object> modify(SingleWorkStep singleWorkStep, Employee employee)throws Exception;
    /**
     * 步骤上移
     * @param stepId
     * @return
     * @throws Exception
     */
    Map<String,Object> upStep(String stepId) throws Exception;
    /**
     * 将步骤下移
     * @param stepId
     * @return
     * @throws Exception
     */
    Map<String, Object> downStep(String stepId) throws Exception;
    /**
     * 删除步骤
     * @param stepId
     * @return
     * @throws Exception
     */
    Map<String,Object> del(String stepId)throws Exception;
    /**
     * 批量删除步骤
     * @param stepIds
     * @return
     * @throws Exception
     */
    Map<String,Object> delBatch(String[] stepIds, String workContentId) throws Exception;
    /**
     * 按ID获取步骤
     * @param stepId
     * @return
     * @throws Exception
     */
    SingleWorkStep getStepById(String stepId)throws Exception;
    /**
     * 一站一案：操作步骤列表获取
     * @param singleWorkStep
     * @return
     * @throws Exception
     */
    Map<String,Object> search(SingleWorkStep singleWorkStep)throws Exception;
    /**
     * 获取操作单元的步骤
     * @param singleWorkStep
     * @return
     * @throws Exception
     */
    Map<String,Object>  getStepByCellId(SingleWorkStep singleWorkStep) throws Exception;

    /**
     * 重新排序
     * @param steplist
     */
    boolean resortStep(List<SingleWorkStep> steplist) throws Exception;

    /**
     * 按步骤ID获取数据项列表
     * @param stepId
     * @return
     * @throws Exception
     */
    List<SingleWorkStepDataItem> getDataItemByStepId(String stepId);
    /**
     * 批量添加数据项（有检验）
     * @param singleWorkStepDataItem
     * @return
     * @throws Exception
     */
    Map<String,Object> addDataItem(SingleWorkStepDataItem[] singleWorkStepDataItem, Employee employee)throws Exception;
    /**
     * 单个添加数据项(无校验)
     * @param dataItem
     * @return
     * @throws Exception
     */
    public Map<String,Object> addDataItem(SingleWorkStepDataItem dataItem)throws Exception;
    /**
     * 修改数据项
     * @param singleWorkStepDataItem
     * @return
     * @throws Exception
     */
    Map<String,Object> modifyDataItem(SingleWorkStepDataItem singleWorkStepDataItem, Employee employee)throws Exception;
    /**
     * 修改数据项（无校验）
     * @param dataItem
     * @return
     */
    public Map<String,Object> modifyDataItemExpValidate(SingleWorkStepDataItem dataItem)throws Exception;
    /**
     * 删除数据项
     * @param dataItemId
     * @return
     * @throws Exception
     */
    Map<String,Object> delDataItem(String dataItemId)throws Exception;

    /**
     * 获取生产实体阈值
     * @param deviceThreshold
     * @return
     * @throws Exception
     */
    Map<String,Object> getEntityThres(DeviceThreshold deviceThreshold)throws Exception;

    /**
     * 获取工作内容对象
     * @param workInstanceId
     * @return
     * @throws Exception
     */
    WorkCellInstance getWorkContent(String workInstanceId) throws Exception;
    /**
     * 新增步骤版本
     * @param workContentId
     * @return
     * @throws Exception
     */
    Map<String,Object> addStepVersion(String workContentId, Employee employee)throws Exception;

    /**
     * 校验数据项参数方法
     * @param singleWorkStepDataItem
     * @return
     */
    public Map<String,Object> isBlank(SingleWorkStepDataItem singleWorkStepDataItem);

    /**
     * 按工作内容获取新版本步骤分页列表
     * @param step
     * @return
     * @throws Exception
     */
    Map<String,Object> getNewVersionStepListByWork(SingleWorkStep step)throws Exception;
    /**
     * 应用新的版本号
     * @param work
     * @return
     */
    Map<String,Object> applyNewVersion(WorkCellInstance work);

    /**
     * 获取步骤数量
     * @param step
     * @return
     * @throws Exception
     */
    public int getStepNum(SingleWorkStep step)throws Exception;


    /**
     * 得到操作单元的操作步骤
     * @param workConetId
     * @return
     */
    List<SingleWorkStep> getStepByWorkContentId(String workConetId, String stepVersion, String isStatus);


    /**
     * 添加步骤
     * @param singleWorkSteps
     * @return
     * @throws Exception
     */
    void addStep(List<SingleWorkStep> singleWorkSteps, String workConetId, Employee employee) throws Exception;


    /**
     * 根据操作单元删除步骤
     */
    Integer delStepByContentId(String cellId) throws Exception;

    /**
     * 得到一站一案操作阶段的数据
     * @param cellId
     * @return
     */
    List<SingleWorkStep> queryStepByTypeAndWorkInstnceId(String cellId);
}
